<!--
 * @Author: ChunLai
 * @Date: 2022-03-31 10:25:28
 * @LastEditTime: 2025-08-15 10:45:03
 * @Description: 投保条款文档阅读
 * @FilePath: \02.bldinsure\src\views\read\index.vue
-->

<template>
  <div class="file_page-index" v-if="pageLoad">
    <PdfReader ref="pdfReadingRef" v-if="fileType === 'pdf'" />
    <HtmlImg :fileObj="fileObj" v-else></HtmlImg>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import HtmlImg from "./HtmlImg";
import PdfReader from "@/components/PdfReader";

export default {
  name: "ReadPage",
  data() {
    return {
      fileType: "pdf",
      fileObj: {},
      pageLoad: false,
    };
  },
  components: {
    HtmlImg,
    PdfReader,
  },
  computed: {
    ...mapGetters({
      pdfWords: "page/pdfWords",
      apiClauseList: "home/apiClauseList",
    }),
    insureFilesList() {
      return [...this.pdfWords, ...this.apiClauseList];
    },
  },
  created() {
    const querys = this.$route.query;
    if (querys.ftype) {
      this.fileType = querys.ftype;
    }
    if (querys.fid) {
      this.fileObj = this.insureFilesList.find((ele) => ele.id == querys.fid);
    }
    this.pageLoad = true;
    if (this.fileType === "pdf") {
      this.$nextTick(() => {
        this.$refs.pdfReadingRef.initModule(this.fileObj.fileUrl);
      });
    }
  },
  methods: {},
};
</script>
